package com.jfinal.aop.config;

import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.InputStream;
import java.util.Properties;
import com.jfinal.aop.Duang;
import com.jfinal.aop.controller.DemoController;
import com.jfinal.aop.interceptor.AopInterceptor;
import com.jfinal.aop.plugin.AopBeanPlugin;
import com.jfinal.aop.spring.SpringBeanManger;
import com.jfinal.config.Constants;
import com.jfinal.config.Handlers;
import com.jfinal.config.Interceptors;
import com.jfinal.config.JFinalConfig;
import com.jfinal.config.Plugins;
import com.jfinal.config.Routes;
import com.jfinal.core.JFinal;
import com.jfinal.kit.PathKit;
import com.jfinal.kit.PropKit;
import com.jfinal.log.Log;
import com.jfinal.plugin.activerecord.ActiveRecordPlugin;
import com.jfinal.plugin.activerecord.cache.EhCache;
import com.jfinal.plugin.activerecord.dialect.OracleDialect;
import com.jfinal.plugin.c3p0.C3p0Plugin;
import com.jfinal.plugin.druid.DruidPlugin;
import com.jfinal.plugin.ehcache.EhCachePlugin;
import com.jfinal.plugin.redis.Redis;
import com.jfinal.plugin.redis.RedisPlugin;
import com.jfinal.render.VelocityRender;
import com.jfinal.render.ViewType;
import com.jfinal.template.Engine;

/**
 * Jfinal Aip引导式配置
 * @author zengjintao
 * @version 1.0
 * @create_at 2017年6月8日 下午9:13:31
 */
@SuppressWarnings("unused")
public class SysConfig extends JFinalConfig{
	
	private static final Log LOG = Log.getLog(SysConfig.class);
	
	@Override
	public void configConstant(Constants constants) {
		 constants.setDevMode(true);
		 constants.setViewType(ViewType.VELOCITY);
		 constants.setEncoding("utf-8");
	}
	@Override
	public void configRoute(Routes routes) {
		routes.add("/", DemoController.class);
	}
	
	
	@Override
	public void configEngine(Engine engine) {
	}
		
	@Override
	public void configPlugin(Plugins plugin) {
	    //aop自动注入插件
	    @SuppressWarnings("rawtypes")
		AopBeanPlugin beanPlugin = new AopBeanPlugin();
	    beanPlugin.setPackageName("com.jfinal.aop.service");
	    plugin.add(beanPlugin);
	}
	
	@Override
	public void configInterceptor(Interceptors interceptors) {
		interceptors.add(new AopInterceptor(SpringBeanManger.getContext()));//aop,spring bean注入拦截器
	}
	
	@Override
	public void configHandler(Handlers handlers) {
	}
	
	/**
	 * 初始化系统数据
	 */
	@Override
	public void afterJFinalStart() {
	}
	
	@Override
	public void beforeJFinalStop() {
	}
}
